package com.example.demo.service.serviceimpl;

import com.example.demo.dao.PurchaseHistoryDao;
import com.example.demo.entity.PurchaseHistoryEntity;
import com.example.demo.service.PurchaseHistoryService;
import com.example.demo.vo.PurchaseHistoryVo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PurchaseHistoryServiceImpl implements PurchaseHistoryService {
    @Resource
    PurchaseHistoryDao purchaseHistoryDao;

    @Override
    public List<PurchaseHistoryEntity> getUserPurchaseHistory(int user_id) {
        return purchaseHistoryDao.getPurchaseHistoryByUserId(user_id);
    }

    @Override
    public PurchaseHistoryEntity getPurchaseHistoryById(int id) {
        return purchaseHistoryDao.getPurchaseHistoryById(id);
    }

    @Override
    public int addPurchaseHistory(PurchaseHistoryVo purchaseHistoryVo) {
        return purchaseHistoryDao.addPurchaseHistory(purchaseHistoryVo);
    }

    @Override
    public int deletePurchaseHistory(int id) {
        return purchaseHistoryDao.delPurchaseHistory(id);
    }

    @Override
    public int updatePurchaseHistory(PurchaseHistoryVo purchaseHistoryVo) {
        return purchaseHistoryDao.updatePurchaseHistory(purchaseHistoryVo);
    }

    @Override
    public List<PurchaseHistoryEntity> getAllPurchaseHistories() {
        return purchaseHistoryDao.getAllPurchaseHistories();
    }
}